package org.example.zrccddllljh.Controlelr;

import org.apache.tomcat.util.digester.RuleSet;
import org.example.zrccddllljh.Pojo.Announcement;
import org.example.zrccddllljh.Pojo.Nurse;
import org.example.zrccddllljh.Pojo.Result;
import org.example.zrccddllljh.Service.AnnouncementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/announcement")
public class AnnouncementController {
@Autowired
    private AnnouncementService announcementService;

    @GetMapping("/all")
    public Result<List<Announcement>> list(){
        List<Announcement> ls=  announcementService.list();
        return Result.success(ls);
    }
    @PostMapping
    public Result add(@RequestBody  Announcement announcement){
        announcementService.add(announcement);
        return Result.success();
    }
    @PutMapping("/updata")
    public  Result updata(@RequestBody  Announcement announcement){

        announcementService.upadte(announcement);
        return Result.success();
    }
    @DeleteMapping

    public Result delete(Integer id){
        announcementService.deleteById(id);
        return Result.success();
    }
}
